package com.iap.app
{
	import com.iap.app.event.AppEvent;
	import com.iap.app.util.logger.Log;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	import mx.managers.CursorManager;

	public class AppGlobal extends EventDispatcher
	{
		public static const VERSION:String = "1.1.5";
		public static const PATH_CONFIG:String = "config.xml";
		public static var IsMultiRunMode:Boolean = false;
		public static var DataServiceEndPoint:String = "http://localhost/IapService/";
		public static var LoginEndPoint:String = "http://localhost/IapService/Login.aspx";
		public static var FileUploadEndPoint:String = "http://localhost/IapService/fileupload.aspx";
		public static var ImageEndPoint:String = "http://localhost/IapService/ImageFile.aspx";

		public static var autoLoginUserName:String = "sam";
		public static var autoLoginUserPass:String = "rockwell";
		
		public static var REPORT_FAVORITE_PDF_NAME:String = "iap_report.pdf";

		public function AppGlobal()
		{
		}

		public function init(loadConfig:Boolean = true):void
		{
			Log.Info("Global.version > " + VERSION);
			initAppConfig();
		}
		
		private function initAppConfig():void
		{
			var config:AppConfig = new AppConfig();
			config.addEventListener(AppEvent.CONFIG_READY, appConfigReady);
			config.init();
		}
		
		private function appConfigReady(evt:Event):void
		{
			(evt.target as AppConfig).removeEventListener(AppEvent.CONFIG_READY, appConfigReady);
			globalReady();
		}

		private function globalReady():void
		{
			dispatchEvent(new AppEvent(AppEvent.GLOBAL_READY));
		}
		
		public static function startWait():void
		{
			CursorManager.setBusyCursor();
		}

		public static function endWait():void
		{
			CursorManager.removeBusyCursor();
		}
	}
}